
from sprite import *
from common import *

class Cactus(GameSprite):
	
	def __init__(self, image_name, **kwargs):
		self.y = 0
		self.dammage = 3
		GameSprite.__init__(self, image_name, **kwargs)
		self.right = False
		self.left = False
		self.speed = 0
		self.health = 1e99
		self.name = "cactus"
		self.touch_ground()
	
	def die(self):
		self.health = 1e99
	
	def draw(self, offset):
		self.image.blit(self.x, self.y)
	
	def update(self, dt):
		for sprite in Game.sprites:
			if (not sprite.name in ("cactus", "arrow") and self.intersect(sprite)):
				load_music("hit.ogg", streaming=False).play()
				if (sprite.name == "player"):
					sprite.health -= self.dammage
				else:
					sprite.health = 0
				sprite.vertical = 0
				sprite.force_jump()
				sprite.killed_by = "cactus"